package com.lifeibiao.homework;

import java.util.Scanner;

public class StringLength {
    public static void main(String[] args) {
        test01();
    }
    public static void test01(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要统计的字符串");
        String str01 = scanner.nextLine();
        System.out.println("输入的字符串为：" + str01);
        //System.out.println(str01.charAt(2));
        int i = 0;
        while (true){
            try {
                str01.charAt(i);
                i++;
            } catch (Exception e) {
             //   e.printStackTrace();
                break;
            } finally {
            }
        }
        System.out.println("字符串长度为："+i);

    }
}
